import Home from '../views/home/home.vue'
import store from '../store'

console.log('store', store.state.login.userInfo.key)

const activeRouter = [
  {
    path: '/',
    name: '首页',
    component: Home,
  },
  {
    path: '/userCenter',
    name: '个人中心',
    component: () => import('../views/pages/userCenter/index.vue'),
  },
  {
    path: '/permission',
    name: '权限设置',
    component: () => import('../views/pages/permission/index.vue'),
  },
  {
    path: '/role',
    name: '角色设置',
    component: () => import('../views/pages/role/index.vue'),
  },
  {
    path: '/user',
    name: '用户设置',
    component: () => import('../views/pages/user/index.vue'),
  },
  {
    path: '/testPage',
    name: '测试页面',
    redirect: '/testPage/testOne',
    component: () => import('../views/pages/testPage/testPage.vue'),
    children: [
      {
        path: 'testOne',
        name: '测试一',
        component: () => import('../views/pages/testPage/testOne/index.vue'),
      },
      {
        path: 'testTwo',
        name: '测试二',
        component: () => import('../views/pages/testPage/testTwo/testTwo.vue'),
      },
    ],
  },
  {
    path: '/workEsp',
    name: '工作经验',
    redirect: '/workEsp/one',
    component: () => import('../views/pages/workEsp/workEsp.vue'),
    children: [
      {
        path: 'one',
        name: '作品一',
        component: () => import('../views/pages/workEsp/one/index.vue'),
      },
      {
        path: 'two',
        name: '作品二',
        component: () => import('../views/pages/workEsp/two/index.vue'),
      },
    ],
  },
  {
    path: '/setTing',
    name: '设置',
    component: () => import('../views/pages/setTing/index.vue'),
  },
]

console.log('user', store?.state?.user?.userList)

const list11 = []
store?.state?.user?.roleList?.forEach((e) => {
  if (e.key == store.state.login.userInfo.key) {
    list11.push(e)
  }
})

console.log('list11', list11)

const list = []

// if (list11[0]) {
activeRouter.forEach((e) => {
  list11?.[0]?.checked.forEach((el) => {
    if (e.name == el) {
      list.push(e)
    }
  })
})
// } else {
// }

console.log('list', list)

const data = list.length > 0 ? list : activeRouter
console.log('data', data)

export default data
